<?
	
	$results = array();
	require_once('../inc/users.php');
	if(isset($_POST['id']))
	{
		$row = $_POST;
		$results = SaveUser($row);
		if($results === true)
		{
			header("Location: index.php");
			die();
		}
	}else{
		$row = GetUser($_REQUEST['id']);
	}
	
?>

<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>Details Of user: <?=$row['FirstName']?> <?=$row['LastName']?></title>
    <link type="text/css" rel="stylesheet" href="../inc/bootstrap.css">
</head>

<body>
		<? include('../inc/header.php'); ?>
        <div class="container">
        	<? include('../inc/nav.php'); ?>
            <div id="contents">
            	<dl class="error">
                	<? foreach ($results as $key => $value): ?>
                    	<dt><?=$key?></dt>
                        <dd><?=$value?></dd>
                    <? endforeach; ?>
                </dl>
                <form class="form-horizontal" method="post" action="">
                	<input type="hidden" name="id" value="<?=$row['id']?>" />
                    <div class="control-group">
                        <label class="control-label" for="FirstName">First Name:</label>
                        <div class="controls">
                        <input type="text" name="FirstName" id="FirstName" value="<?=$row['FirstName']?>"/> 
                        </div>
                    </div>
                    
                    <div class="control-group">    
                        <label class="control-label" for="LastName">Last Name:</label>
                        <div class="controls">
                        <input type="text" name="LastName" id="LastName" value="<?=$row['LastName']?>"/>
                        </div>
                    </div>
                    
                    <div class="control-group">    
                        <label class="control-label" for="PhoneNumber">Phone Number:</label>
                        <div class="controls">
                        <input type="text" name="PhoneNumber" id="PhoneNumber" value="<?=$row['PhoneNumber']?>"/>
                        </div>
                    </div>
                    
                    <div class="control-group">    
                        <label class="control-label" for="Email">Email:</label>
                        <div class="controls">
                        <input type="text" name="Email" id="Email" value="<?=$row['Email']?>"/>
                        </div>
                    </div>
                    
                    <div class="control-group">    
                        <label class="control-label" for="UserName">User Name:</label>
                        <div class="controls">
                        <input type="text" name="UserName" id="UserName" value="<?=$row['UserName']?>"/>
                        </div>
                    </div>
                    
                    <div class="control-group">    
                        <label class="control-label" for="Password">Password:</label>
                        <div class="controls">
                        <input type="text" name="Password" id="Password" value="<?=$row['Password']?>"/>
                        </div>
                    </div>
                    
                    <input class="btn btn-primary" type="submit" value="Save" />
                </form>
            </div>
        </div>
</body>
</html>